package com.example.service.impl2;

import com.example.entity.TianLuo;
import com.example.mapper.TianLuoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class TianluoFlowService {
    @Autowired
    private TianLuoMapper tianLuoMapper;

    // @Transactional(propagation = Propagation.NESTED) // methodA抛异常methodB正常 A与B一起回滚
    @Transactional(propagation = Propagation.REQUIRES_NEW)// methodA抛异常methodB正常	A回滚，B正常提交
    public void saveFlow(String data) {
        TianLuo tianLuo = new TianLuo();
        tianLuo.setName(data);
        tianLuoMapper.insert(tianLuo);
        int i = 1 / 0;
    }

}
